/////precompiled////////
#include "precompiled.h"
////////////////////////


#include "prs_FrmStyle.h"
using namespace prs;

// TNodeStyle /////////////////////////////////////////////////////////////////

//
TNodeStyleControl *TNodeStyle::SearchStyleControlByType(svl::TString NodeControlType)
{
  TNode *Node = TNodeSearch(this)
   .SearchChildren()
    .SearchByType(NodeControlType)
     .GetFirst();

  if (Node) {
    TNodeStyleControl *StyleControl = dynamic_cast<TNodeStyleControl*>(Node); 
    if (!StyleControl) {
      Except("SearchStyleControlByType[!StyleControl]");
    } 
    return StyleControl;
  }
  return NULL;
}

//
TNodeStyle *TNodeStyle::searchStyleByIdFromChild(
  TAttrNode *FromChild,
  const svl::TString &StyleId
)
{
  TNode *Node = TNodeSearch(FromChild)
   .SearchNearThisOrParentByType(nodeType_Root)
   //.SearchFarThisOrParentByType(nodeType_Unit)
   .GotoChildren(attrName_Units)
   //.AddChildren(attrName_Units,true)
   .GotoChildren(attrName_OldChildren)
    .SearchByType(nodeType_Style)
    .SearchById(StyleId)
    .GetFirst();

//if (!Node) {
//Node=Node;
//}

  return dynamic_cast<TNodeStyle*>(Node); 
}
